<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/pages/common/common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>爱德夏</title>
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <script type="text/javascript" language="javascript">
        var centerTabs;
        var tabsMenu;
        var numtabs;
        $(function () {
            numtabs = 0;
            tabsMenu = $('#tabsMenu').menu({
                onClick : function(item) {
                    var curTabTitle = $(this).data('tabTitle');
                    var type = $(item.target).attr('type');

                    if (type === 'close') {
                        var t = centerTabs.tabs('getTab', curTabTitle);
                        if (t.panel('options').closable) {
                            centerTabs.tabs('close', curTabTitle);
                        }
                        return;
                    }

                    var allTabs = centerTabs.tabs('tabs');
                    var closeTabsTitle = [];

                    $.each(allTabs, function() {
                        var opt = $(this).panel('options');
                        if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
                            closeTabsTitle.push(opt.title);
                        } else if (opt.closable && type === 'closeAll') {
                            closeTabsTitle.push(opt.title);
                        }
                    });

                    for ( var i = 0; i < closeTabsTitle.length; i++) {
                        centerTabs.tabs('close', closeTabsTitle[i]);
                    }
                }
            });
            centerTabs = $('#centerTabs').tabs({
                border : false,
                fit : true,
                onClose: function(title){
                    return numtabs --;
                },
                onContextMenu : function(e, title) {
                    e.preventDefault();
                    tabsMenu.menu('show', {
                        left : e.pageX,
                        top : e.pageY
                    }).data('tabTitle', title);
                }
            });
        });
        function addTabFun(node) {
        	if(numtabs<10){
    			if (node.attributes.url && node.attributes.url.length > 0) {
    				if(node.attributes.url != '#'){
    					var options = $.extend({
        					iconCls : 'icon-reload',
        	            	title : node.text,
        	                content : '<iframe src="${path}' + node.attributes.url + '" frameborder="0" style="border:0;width:100%;height:99.2%;"></iframe>',
        	                closable : true
        	            }, node);
        				if (centerTabs.tabs('exists', options.title)) {
        	                centerTabs.tabs('close', options.title);
        	            }
        	            centerTabs.tabs('add', options);
        	            imonJYRH.showZone();
        	            numtabs ++;
    				}
    			} else {
    				addTabs({
    					src : '',
    					title : '工程建设'
    				});
    				numtabs ++;
    			} 
			} else {
				$.messager.alert('提示','您已经打开很多页面了，请关掉其他画面再打开新的画面！','prompt');
			}
        };
        function exitSystem(action){
            if (confirm('您确定要退出系统吗？'))
                window.parent.location=action;
        }
        var operateDialog;
        var message= $.messager;
        function changeUserPassword_(){
            var href = "${path}/config/sys/user/user_editCurrentUI.do?user.tsUserInfoId=${sessionUser.tsUserInfoId}";
            operateDialog = $("#operateDialog").dialog({});
            $("#operateIFrame")[0].src=imonJYRH.url(href);
            operateDialog.dialog('open');
            imonJYRH.showZone();
        }
    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:true" style="height:50px;background:#cce8d1;">
    <div style="position:absolute;left:4px;top:0px;">
        <img height="50px" src="${path}/resources/img/main/logo.jpg">
    </div>
    <div style="position:absolute;right:0px;bottom:0px;display:inline;">
        <span style="height:18px;line-height:12px;"><!-- ${sessionUser.personName}-->系统管理员,欢迎您！</span>
        <a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-edit-password" onclick="changeUserPassword_();">修改密码</a>
        <a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-back" onclick="exitSystem('logout.do')">登出</a>
    </div>
</div>
<div data-options="region:'west',split:true,title:'Nav/导航',
	tools : [ {
			iconCls :'icon-reload',
			handler : function() {
			ctrlTree.tree('reload');
			}
		}, {
			iconCls : 'icon-redo',
			handler : function() {
				ctrlTree.tree('expandAll');
			}
		}, {
			iconCls : 'icon-undo',
			handler : function() {
				ctrlTree231.tree('collapseAll');
			}
		} ]" style="width:205px;">
    <ul id="ctrlTree" style="margin-top: 5px;" data-options="lines:true"></ul>
    <script type="text/javascript">
		 var ctrlTree = $('#ctrlTree').tree({
			url:'${path}/sys/user/ajaxTreeGrid.do',
   			lines : true,
   			onClick : function(node) {
   				addTabFun(node);
   			}
   		});
	</script>
</div>
<div data-options="region:'center'">
    <div id="centerTabs"></div>
    <div id="tabsMenu" style="width:120px;display:none;">
        <div type="close">关闭</div>
        <div class="menu-sep"></div>
        <div type="closeOther">关闭其他</div>
        <div type="closeAll">关闭所有</div>
    </div>
</div>
<div data-options="region:'south'">
    <div align="center" style="height:18px">版权所有 上海爱德夏，推荐分辨率1024*768+，使用火狐浏览器可以获得更快的页面响应速度</div>
</div>
<div id="operateDialog" class="easyui-dialog" title="修改当前用户密码" style="width:600px;height:350px;"
     data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
    <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
</div>
</body>
</html>